/* Ejercicio 5.11
   ejer5_11.c */
#include <stdio.h>
#include <math.h>

/* Prototypes */
double roundToInteger( double number );
double roundToTenths( double number );
double roundToHundreths( double number );
double roundToThousandths( double number );

/* function main begins program execution */
int main( void )
{
    double number;

    printf( "Enter a number: " );
    scanf( "%lf", &number );

    printf( "Number %f\nTo Integer: %f\nTo Tenths: %f\nTo Hundreths: %f\nTo Thousanths: %f\n",
           number, roundToInteger( number ), roundToTenths( number ),
           roundToHundreths( number ), roundToThousandths( number ) );
	return 0;
} /* end function main */

/* Round a number to Integer */
double roundToInteger( double number )
{
    return floor( number + .5 );
} /* End function roundToInteger */

/* Round a number to Tenths */
double roundToTenths( double number )
{
    return floor( number * 10 + .5 ) / 10;
} /* End function roundToThenths */

/* Round a number to Hundreths */
double roundToHundreths( double number )
{
    return floor( number * 100 + .5 ) / 100;
} /* End function roundToHundreths */

/* Round a number to Thousandths */
double roundToThousandths( double number )
{
    return floor( number * 1000 + .5 ) / 1000;
} /* End function roundToThousandths */
